package com.woniu.supermarket.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.supermarket.entity.Supplier;
import com.woniu.supermarket.mapper.SupplierMapper;
import com.woniu.supermarket.service.ISupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierServiceImpl implements ISupplierService {
    @Autowired
    SupplierMapper supplierMapper;

    @Override
    public PageInfo<Supplier> queryByPage(Integer now, Integer size, String name) {
        PageHelper.startPage(now,size);
        List<Supplier> lists = supplierMapper.selectByCons(name);
        return new PageInfo<>(lists);
    }

    @Override
    public int add(Supplier supplier) {
        return supplierMapper.insert(supplier);
    }

    @Override
    public int remove(int id) {
        return supplierMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int modify(Supplier supplier) {
        return supplierMapper.updateByPrimaryKey(supplier);
    }

    @Override
    public List<Supplier> findAll() {
        return supplierMapper.selectAll();
    }
}
